<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TechBlog - Github风格技术博客</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            /* 亮色主题变量 */
            --bg-color: #ffffff;
            --text-color: #24292f;
            --border-color: #d0d7de;
            --card-bg: #f6f8fa;
            --header-bg: #f6f8fa;
            --accent-color: #0969da;
            --accent-hover: #0550ae;
            --code-bg: rgba(175, 184, 193, 0.2);
            --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
            --tag-bg: #ddf4ff;
            --tag-color: #0969da;
        }

        .dark-theme {
            /* 深色主题变量 */
            --bg-color: #0d1117;
            --text-color: #e6edf3;
            --border-color: #30363d;
            --card-bg: #161b22;
            --header-bg: #161b22;
            --accent-color: #2f81f7;
            --accent-hover: #1c6bdb;
            --code-bg: rgba(110, 118, 129, 0.4);
            --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.7);
            --tag-bg: #388bfd26;
            --tag-color: #58a6ff;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            transition: background-color 0.3s, color 0.3s, border-color 0.3s;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            line-height: 1.5;
        }

        .container {
            max-width: 1280px;
            margin: 0 auto;
            padding: 0 20px;
        }

        /* 头部导航 */
        header {
            background-color: var(--header-bg);
            border-bottom: 1px solid var(--border-color);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 0;
            position: relative;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 10px;
            font-weight: 600;
            font-size: 20px;
            color: var(--text-color);
            text-decoration: none;
            z-index: 101;
        }

        .logo i {
            color: var(--accent-color);
        }

        .nav-links {
            display: flex;
            gap: 24px;
        }

        .nav-links a {
            color: var(--text-color);
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .nav-links a:hover {
            color: var(--accent-color);
        }

        .nav-links a.active {
            color: var(--accent-color);
            font-weight: 600;
        }

        .nav-actions {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .theme-toggle {
            background: none;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 8px 12px;
            color: var(--text-color);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 14px;
            transition: all 0.2s ease;
        }

        .theme-toggle:hover {
            background-color: var(--code-bg);
        }

        .mobile-menu {
            display: none;
            background: none;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            color: var(--text-color);
            cursor: pointer;
            padding: 8px 12px;
            font-size: 16px;
            transition: all 0.2s ease;
        }

        .mobile-menu:hover {
            background-color: var(--code-bg);
        }

        /* 主要内容区域 - 修改为flex布局 */
        .main-content {
            display: flex;
            flex-direction: column;
            gap: 24px;
            padding: 32px 0;
        }

        /* 文章标题区域 */
        .section-header {
            margin-bottom: 0;
        }

        .section-header h2 {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 0;
        }

        /* 内容容器 - 侧边栏和文章列表的父容器 */
        .content-container {
            display: flex;
            gap: 32px;
            align-items: flex-start;
            /* 确保顶部对齐 */
        }

        /* 文章列表区域 */
        .articles-section {
            flex: 1;
            min-width: 0;
            /* 防止flex项目溢出 */
        }

        /* 文章卡片 */
        .article-card {
            background-color: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 24px;
            margin-bottom: 16px;
            /* box-shadow: var(--shadow); */
            transition: border-color 0.2s ease;
        }

        .article-card:hover {
            border-color: var(--accent-color);
        }

        .article-title {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 8px;
        }

        .article-title a {
            color: var(--accent-color);
            text-decoration: none;
        }

        .article-title a:hover {
            text-decoration: underline;
        }

        .article-meta {
            display: flex;
            gap: 16px;
            margin-bottom: 12px;
            font-size: 14px;
            color: var(--text-color);
            opacity: 0.8;
        }

        .article-tags {
            display: flex;
            gap: 8px;
            margin-bottom: 12px;
            flex-wrap: wrap;
        }

        .tag {
            background-color: var(--tag-bg);
            color: var(--tag-color);
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
        }

        .article-excerpt {
            margin-bottom: 16px;
            font-size: 14px;
        }

        .read-more {
            color: var(--accent-color);
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .read-more:hover {
            text-decoration: underline;
        }

        /* 侧边栏 */
        .sidebar {
            width: 300px;
            flex-shrink: 0;
            /* 防止侧边栏缩小 */
            display: flex;
            flex-direction: column;
            gap: 24px;
        }

        /* 侧边栏区块 */
        .sidebar-section {
            background-color: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 16px;
        }

        .sidebar-section h3 {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 12px;
            padding-bottom: 8px;
            border-bottom: 1px solid var(--border-color);
        }

        .about-me {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
        }

        .avatar {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            margin-bottom: 12px;
            border: 2px solid var(--border-color);
        }

        .social-links {
            display: flex;
            gap: 12px;
            margin-top: 12px;
        }

        .social-links a {
            color: var(--text-color);
            font-size: 18px;
            transition: color 0.2s ease;
        }

        .social-links a:hover {
            color: var(--accent-color);
        }

        .categories-list,
        .tags-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .categories-list a,
        .tags-list a {
            background-color: var(--code-bg);
            color: var(--text-color);
            padding: 4px 8px;
            border-radius: 6px;
            text-decoration: none;
            font-size: 12px;
            transition: all 0.2s ease;
        }

        .categories-list a:hover,
        .tags-list a:hover {
            background-color: var(--accent-color);
            color: white;
        }

        /* 代码块样式 */
        pre {
            background-color: var(--code-bg);
            border-radius: 6px;
            padding: 16px;
            overflow-x: auto;
            margin: 16px 0;
            font-size: 14px;
            border: 1px solid var(--border-color);
        }

        code {
            font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
        }

        /* 页脚 */
        footer {
            border-top: 1px solid var(--border-color);
            padding: 32px 0;
            text-align: center;
            font-size: 14px;
            color: var(--text-color);
            opacity: 0.8;
        }

        /* 响应式设计优化 */
        /* 中等屏幕 (平板横屏) */
        @media (max-width: 1024px) {
            .content-container {
                gap: 24px;
            }

            .sidebar {
                width: 250px;
            }

            .article-card {
                padding: 20px;
            }
        }

        /* 小屏幕 (平板竖屏) */
        @media (max-width: 900px) {
            .content-container {
                flex-direction: column;
            }

            .sidebar {
                width: 100%;
                order: -1;
                margin-bottom: 0;
            }

            .sidebar-section {
                padding: 20px;
            }
        }

        /* 移动端优化 */
        @media (max-width: 768px) {
            .container {
                padding: 0 16px;
            }

            .navbar {
                padding: 12px 0;
            }

            .logo {
                font-size: 18px;
            }

            .nav-links {
                position: absolute;
                top: 100%;
                left: 0;
                width: 100%;
                background-color: var(--header-bg);
                border-top: 1px solid var(--border-color);
                flex-direction: column;
                padding: 16px 20px;
                display: none;
                box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            }

            .nav-links.active {
                display: flex;
            }

            .nav-links a {
                padding: 12px 0;
                border-bottom: 1px solid var(--border-color);
                font-size: 16px;
            }

            .nav-links a:last-child {
                border-bottom: none;
            }

            .mobile-menu {
                display: block;
                min-height: 44px;
                min-width: 44px;
                display: flex;
                align-items: center;
                justify-content: center;
            }

            .theme-toggle,
            .mobile-menu {
                padding: 10px 14px;
            }

            .main-content {
                padding: 24px 0;
                gap: 20px;
            }

            .content-container {
                gap: 20px;
            }

            .section-header h2 {
                font-size: 20px;
            }

            .article-card {
                padding: 16px;
                margin-bottom: 12px;
            }

            .article-title {
                font-size: 18px;
            }

            .article-meta {
                flex-wrap: wrap;
                gap: 8px;
                font-size: 13px;
            }

            pre {
                padding: 12px;
                font-size: 13px;
            }

            .sidebar-section {
                padding: 16px;
            }

            .avatar {
                width: 60px;
                height: 60px;
            }

            .read-more,
            .categories-list a,
            .tags-list a {
                padding: 8px 12px;
                font-size: 14px;
            }

            /* 减少移动端的动画效果 */
            * {
                transition: none;
            }

            /* 保留必要的过渡 */
            .theme-toggle,
            .mobile-menu,
            .nav-links a,
            .read-more {
                transition: all 0.2s ease;
            }
        }

        /* 小屏手机优化 */
        @media (max-width: 480px) {
            .article-meta {
                flex-direction: column;
                gap: 4px;
            }

            .article-tags {
                gap: 6px;
            }

            .categories-list,
            .tags-list {
                gap: 6px;
            }

            .container {
                padding: 0 12px;
            }

            .content-container {
                gap: 16px;
            }
        }

        /* 横屏模式优化 */
        @media (max-height: 500px) and (orientation: landscape) {
            .navbar {
                padding: 8px 0;
            }

            .main-content {
                padding: 16px 0;
            }

            .article-card {
                padding: 12px;
                margin-bottom: 8px;
            }
        }
    </style>
</head>

<body class="light-theme">
    <header>
        <div class="container">
            <nav class="navbar">
                <a href="#" class="logo">
                    <i class="fas fa-code"></i>
                    TechBlog
                </a>

                <div class="nav-links">
                    <a href="index.html" class="active">首页</a>
                    <a href="article-list.html">文章</a>
                    <a href="tutorial-list.html">教程</a>
                    <a href="projects.html">项目</a>
                    <a href="about.html">关于</a>
                </div>

                <div class="nav-actions">
                    <button class="theme-toggle" id="themeToggle">
                        <i class="fas fa-moon"></i>
                        <span>深色模式</span>
                    </button>
                    <button class="mobile-menu" id="mobileMenu">
                        <i class="fas fa-bars"></i>
                    </button>
                </div>
            </nav>
        </div>
    </header>

    <div class="container">
        <div class="main-content">
            <!-- 标题放在flex容器外面 -->
            <div class="section-header">
                <h2>最新文章</h2>
            </div>

            <!-- 侧边栏和文章列表放在同一个flex容器中 -->
            <div class="content-container">
                <main class="articles-section">
                    <article class="article-card">
                        <h3 class="article-title">
                            <a href="#">深入理解React Hooks的工作原理</a>
                        </h3>
                        <div class="article-meta">
                            <span><i class="far fa-calendar"></i> 2023-10-15</span>
                            <span><i class="far fa-clock"></i> 8分钟阅读</span>
                            <span><i class="far fa-eye"></i> 1.2k浏览</span>
                        </div>
                        <div class="article-tags">
                            <span class="tag">React</span>
                            <span class="tag">JavaScript</span>
                            <span class="tag">前端</span>
                        </div>
                        <p class="article-excerpt">
                            本文将深入探讨React Hooks的内部实现机制，包括useState、useEffect等常用Hook的工作原理，以及如何避免常见的性能陷阱。
                        </p>
                        <pre><code>function Example() {
  const [count, setCount] = useState(0);

  useEffect(() => {
    document.title = `You clicked ${count} times`;
  });

  return (
    &lt;div&gt;
      &lt;p&gt;You clicked {count} times&lt;/p&gt;
      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;
        Click me
      &lt;/button&gt;
    &lt;/div&gt;
  );
}</code></pre>
                        <a href="#" class="read-more">阅读全文 →</a>
                    </article>

                    <article class="article-card">
                        <h3 class="article-title">
                            <a href="#">使用CSS Grid构建现代响应式布局</a>
                        </h3>
                        <div class="article-meta">
                            <span><i class="far fa-calendar"></i> 2023-10-10</span>
                            <span><i class="far fa-clock"></i> 6分钟阅读</span>
                            <span><i class="far fa-eye"></i> 890浏览</span>
                        </div>
                        <div class="article-tags">
                            <span class="tag">CSS</span>
                            <span class="tag">布局</span>
                            <span class="tag">响应式设计</span>
                        </div>
                        <p class="article-excerpt">
                            CSS Grid布局是现代Web开发中强大的布局工具。本文将介绍如何使用Grid创建复杂的响应式布局，并分享一些实用技巧和最佳实践。
                        </p>
                        <a href="#" class="read-more">阅读全文 →</a>
                    </article>

                    <article class="article-card">
                        <h3 class="article-title">
                            <a href="#">Node.js性能优化指南</a>
                        </h3>
                        <div class="article-meta">
                            <span><i class="far fa-calendar"></i> 2023-10-05</span>
                            <span><i class="far fa-clock"></i> 10分钟阅读</span>
                            <span><i class="far fa-eye"></i> 1.5k浏览</span>
                        </div>
                        <div class="article-tags">
                            <span class="tag">Node.js</span>
                            <span class="tag">后端</span>
                            <span class="tag">性能优化</span>
                        </div>
                        <p class="article-excerpt">
                            在这篇文章中，我们将探讨Node.js应用程序的性能优化策略，包括内存管理、异步编程最佳实践、集群模式以及常用的性能分析工具。
                        </p>
                        <a href="#" class="read-more">阅读全文 →</a>
                    </article>
                </main>

                <aside class="sidebar">
                    <div class="sidebar-section about-me">
                        <img src="https://avatars.githubusercontent.com/u/583231?v=4" alt="Avatar" class="avatar">
                        <h3>关于作者</h3>
                        <p>全栈开发者，专注于现代Web技术。热爱开源，喜欢分享技术知识。</p>
                        <div class="social-links">
                            <a href="#"><i class="fab fa-github"></i></a>
                            <a href="#"><i class="fab fa-twitter"></i></a>
                            <a href="#"><i class="fab fa-linkedin"></i></a>
                            <a href="#"><i class="fas fa-envelope"></i></a>
                        </div>
                    </div>

                    <div class="sidebar-section">
                        <h3>分类</h3>
                        <div class="categories-list">
                            <a href="#">JavaScript</a>
                            <a href="#">React</a>
                            <a href="#">Vue</a>
                            <a href="#">Node.js</a>
                            <a href="#">CSS</a>
                            <a href="#">性能优化</a>
                            <a href="#">算法</a>
                            <a href="#">数据库</a>
                        </div>
                    </div>

                    <div class="sidebar-section">
                        <h3>热门标签</h3>
                        <div class="tags-list">
                            <a href="#">前端</a>
                            <a href="#">后端</a>
                            <a href="#">全栈</a>
                            <a href="#">教程</a>
                            <a href="#">开源</a>
                            <a href="#">工具</a>
                            <a href="#">最佳实践</a>
                            <a href="#">TypeScript</a>
                        </div>
                    </div>

                    <div class="sidebar-section">
                        <h3>订阅更新</h3>
                        <p>获取最新技术文章和教程</p>
                        <form style="margin-top: 12px;">
                            <input type="email" placeholder="输入您的邮箱"
                                style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; background: var(--bg-color); color: var(--text-color); margin-bottom: 8px;">
                            <button type="submit"
                                style="width: 100%; padding: 8px; background: var(--accent-color); color: white; border: none; border-radius: 4px; cursor: pointer;">订阅</button>
                        </form>
                    </div>
                </aside>
            </div>
        </div>
    </div>

    <footer>
        <div class="container">
            <p>© 2023 TechBlog. 保留所有权利。</p>
            <p>采用 Github 风格设计 | 由开发者为开发者打造</p>
        </div>
    </footer>

    <script>
        // 主题切换功能
        const themeToggle = document.getElementById('themeToggle');
        const themeIcon = themeToggle.querySelector('i');
        const themeText = themeToggle.querySelector('span');

        // 检查本地存储的主题偏好
        const currentTheme = localStorage.getItem('theme') || 'light';
        if (currentTheme === 'dark') {
            document.body.classList.add('dark-theme');
            themeIcon.classList.remove('fa-moon');
            themeIcon.classList.add('fa-sun');
            themeText.textContent = '浅色模式';
        }

        themeToggle.addEventListener('click', () => {
            document.body.classList.toggle('dark-theme');

            if (document.body.classList.contains('dark-theme')) {
                themeIcon.classList.remove('fa-moon');
                themeIcon.classList.add('fa-sun');
                themeText.textContent = '浅色模式';
                localStorage.setItem('theme', 'dark');
            } else {
                themeIcon.classList.remove('fa-sun');
                themeIcon.classList.add('fa-moon');
                themeText.textContent = '深色模式';
                localStorage.setItem('theme', 'light');
            }
        });

        // 移动端菜单切换
        const mobileMenu = document.getElementById('mobileMenu');
        const navLinks = document.querySelector('.nav-links');
        const menuIcon = mobileMenu.querySelector('i');

        mobileMenu.addEventListener('click', () => {
            navLinks.classList.toggle('active');

            if (navLinks.classList.contains('active')) {
                menuIcon.classList.remove('fa-bars');
                menuIcon.classList.add('fa-times');
            } else {
                menuIcon.classList.remove('fa-times');
                menuIcon.classList.add('fa-bars');
            }
        });

        // 点击菜单外区域关闭菜单
        document.addEventListener('click', (e) => {
            if (!e.target.closest('.navbar') && navLinks.classList.contains('active')) {
                navLinks.classList.remove('active');
                menuIcon.classList.remove('fa-times');
                menuIcon.classList.add('fa-bars');
            }
        });

        // 窗口大小变化时调整菜单状态
        window.addEventListener('resize', () => {
            if (window.innerWidth > 768) {
                navLinks.classList.remove('active');
                menuIcon.classList.remove('fa-times');
                menuIcon.classList.add('fa-bars');
            }
        });
    </script>
</body>

</html>